import { getArea } from "@/utils/api";

//地图
const city = {
  namespaced: true,
  state: () => ({
    getCityList: [], //主数据
  }),
  actions: {
    //获取城市列表数据
    async cityData({ commit }) {
      let res = await getArea();
      commit("cityDatas", res.result);
    },
  },
  mutations: {
    //获得并设置城市列表数据
    cityDatas(state, payload) {
      state.getCityList = payload;
    },
  },
  getters: {
    //字母
    indexList(state) {
      return state.getCityList.map((el) => {
        return el.prefix.toUpperCase();
      });
    },
  },
};

export default city;
